create

@ObjCName(swiftName = "create")
fun BackgroundTaskManager.Companion.create(eventListener: BackgrounderEventListener = BackgrounderEventListener.Noop): BackgroundTaskManager

macOS factory for BackgroundTaskManager.

Hold the returned instance for the lifetime of the app — typically as a stored property on AppDelegate. The Swift call site reads:

let backgrounder = BackgroundTaskManager.companion.create()
backgrounder.register(taskId: SyncWorker.companion.ID) { /* SyncWorker(…) */}
backgrounder.start()

Return

a constructed but not-yet-started BackgroundTaskManager. Call BackgroundTaskManager.register for every task id, then BackgroundTaskManager.start from applicationDidFinishLaunching.

Call BackgroundTaskManager.shutdown from applicationWillTerminate to cancel the scheduler's coroutine scope cleanly.

The pre-execution WorkConstraints.networkRequired gate reads from Reachability.shared (process-lifetime singleton). Tests install a FakeReachability via the :reachable-testing artifact's withFakeReachability { … } helper.

@OptIn(ExperimentalObjCName::class): required by SKIE for the Swift-rename annotation. Stable in practice.

Parameters

eventListener

observability hook for onScheduled, onStarted, onCompleted, onCancelled. Defaults to BackgrounderEventListener.Noop.